package aplicacao.desktop.telefone;

public class DesktopCall {

  public static final void main(String args[]) {

    /*
     * Create a provider by first obtaining the default implementation of
     * JTAPI and then the default provider of that implementation.
     */
    Provider myprovider = null;
    try {
      JtapiPeer peer = JtapiPeerFactory.getJtapiPeer(null);
      myprovider = peer.getProvider(null);
    } catch (Exception excp) {
      System.out.println("Can't get Provider: " + excp.toString());
      System.exit(0);
    }


    /*
     * Create a new telephone call object and place an observer on it.
     */
    Call mycall = null;
    try {
      mycall = myprovider.createCall();
      mycall.addObserver(new DesktopCallObserver());
    } catch (Exception excp) {
      // Handle all Exceptions
    }

    /*
     * Locate the Terminal and Address associated with our near end and place
     * a telephone call to a destination address. We are assuming that
     * Terminals are named after the primary telephone number on that Terminal.
     */
    try {
      Address address = myprovider.getAddress("4761111");
      Terminal terminal = address.getTerminal("4761111");

      mycall.connect(terminal, address, "5551212");
    } catch (Exception excp) {
      // Handle all Exceptions
    }
  }
}


